//
//  XYBookDetailCell.swift
//  XYReadBook
//
//  Created by fox on 2017/9/8.
//  Copyright © 2017年 tsaievan. All rights reserved.
//

import UIKit

class XYBookDetailCell: UICollectionViewCell {
    var model:XYIntroduceModel? {
        didSet {
            if let model = model {
                
                titleLab.text = model.title
                let imageUrl = BaseUrl.image.rawValue.appending(model.cover)//cover_default
                iconImage.setImageView(urlString: imageUrl, placeHolder: "Image_loading")
            }
        }
    }
    
    var iconImage = UIImageView()
    var titleLab = UILabel()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    
    func setupUI() {
        contentView.addSubview(iconImage)
        contentView.addSubview(titleLab)
        iconImage.backgroundColor = UIColor.red
        titleLab.textAlignment = .center
        titleLab.text = "异界邪尊"
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        iconImage.frame = CGRect.init(x: 0, y: 0, width: self.width, height: self.height * 0.8)
        titleLab.frame = CGRect.init(x: 0, y: iconImage.frame.maxY, width: self.width, height: self.height * 0.2)
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
